package io;

import java.io.File;
import java.io.IOException;

import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;


public class XMLReader {
	
	final String XML_PATH = System.getProperty("user.dir") + "/data/";
	
	public Document readXML(String fileName){		
		Document document = null;		
		SAXBuilder sb = new SAXBuilder();
					
		try {
			File file = new File(XML_PATH + fileName);	
			document = (Document) sb.build(file);
		}
		catch (JDOMException e) {
			e.printStackTrace();
		}
		catch (IOException e) {
			e.printStackTrace();
		}		
		
		return document;		
	}	
	
	public Document readXML(File file){		
		Document document = null;		
		SAXBuilder sb = new SAXBuilder();
					
		try {
			document = (Document) sb.build(file);
		}
		catch (JDOMException e) {
			e.printStackTrace();
		}
		catch (IOException e) {
			e.printStackTrace();
		}		
		
		return document;		
	}	
}
